{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bb43b848",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "### 1.字典的三种创建方法\n",
    "### 2.字典的性质\n",
    "> 1. 无序的\n",
    "> 2. key唯一\n",
    "> 3. key不可变\n",
    "# 本周内容\n",
    "### 1.字典的循环遍历\n",
    "### 2.字典的一般方法\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cd403441",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"stu100001\":\"nana\",\n",
    "    \"stu100002\":\"coco\",\n",
    "    \"stu100003\":\"huihui\"\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "68ec2fb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu100001': 'nana', 'stu100002': 'coco', 'stu100003': 'huihui'}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "af959024",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu100001\n",
      "stu100002\n",
      "stu100003\n"
     ]
    }
   ],
   "source": [
    "for i in info:  #运行出来只有冒号前的内容\n",
    "    print(i)  #i 只是指代 key 的值，并没有真正意义上的内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f365a847",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu100001 nana\n",
      "stu100002 coco\n",
      "stu100003 huihui\n"
     ]
    }
   ],
   "source": [
    "# 字典的循环  key：value 作为 items输出\n",
    "for k,v in info.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5ac94f53",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践1：学号的k 去掉 stu 然后输出新的字典\n",
    "new_info = {}\n",
    "\n",
    "for k,v in info.items():\n",
    "    # 字典的新增\n",
    "    new_info[k[3:]] = v.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3acb4069",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'100001': 'NANA', '100002': 'COCO', '100003': 'HUIHUI'}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "db6deae3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
